﻿using System;
using UnityEngine;

/// <summary>
/// 玩家的属性
/// 观察者模式
/// </summary>
[System.Serializable]
public class PlayerAttr{
    #region field
    [Tooltip("物理移动速度")]
    public float rigSpeed = 1;
    [Tooltip("变换移动速度")]
    public float trSpeed = 1;
    [Tooltip("跳跃速度")]
    public float jumpVelocity = 10;
    [Tooltip("加速力")]
    public float force = 10;
    private bool isGround = true;
    [SerializeField, Tooltip("玩家开始面朝右方"),ReadOnly]
    private bool lookAtLeft = false;
    [ReadOnly]
    public bool isWalking = false;
    [Tooltip("蓄力标志"),SerializeField]
    private bool isHolding = false;
    [ReadOnly]
    public bool isFlying = false;
    public ShotAttr shotAttr = new ShotAttr() { maxAngle = 45,startVelocity=2,distance=0.4f,dueTime=5 };
    #endregion
    #region attr

    public bool LookAtLeft
    {
        get
        {
            return lookAtLeft;
        }

        set
        {
            lookAtLeft = value;
            if(OnLookDirChange!=null)
            OnLookDirChange(value);
        }
    }

    public bool IsHolding
    {
        get
        {
            return isHolding;
        }

        set
        {
            isHolding = value;
            if(OnIsHoldingChange!=null)
            OnIsHoldingChange(value);
        }
    }

    public bool IsGround
    {
        get
        {
            return isGround;
        }

        set
        {
            isGround = value;
            if(OnIsGroundChange!=null)
            OnIsGroundChange(value);
        }
    }

    #endregion
    #region event

    public event Action<bool> OnLookDirChange;
    public event Action<bool> OnIsHoldingChange;
    public event Action<bool> OnIsGroundChange; 
    #endregion
}
[System.Serializable]
public struct ShotAttr
{
    [Tooltip("射击角度")]
    public float maxAngle;
    [Tooltip("发射速度")]
    public float startVelocity;
    [Tooltip("发射距离")]
    public float distance;
    public float dueTime;
}
